//
//  HOAboutViewController.m
//  WeiDu_1_0
//
//  Created by foguo-mac-1 on 01/07/16.
//  Copyright (c) 2016 WeiDu Energy Tech. All rights reserved.
//

#import "HOAboutViewController.h"
#import "HOUtils.h"
#import "HOBaseTableViewCell.h"
#import "NDate.h"
#import "HOConstants.h"

@interface HOAboutViewController ()

@end

@implementation HOAboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UILabel *lbl = [[[UILabel alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 115 - 20, self.view.frame.size.width, 46)] autorelease];
    lbl.text = NSLocalizedString(@"杭州微度能源科技有限公司合作 版权所有\n Copyright 2017-2020", @"杭州微度能源科技有限公司合作 版权所有\n Copyright 2017-2020");
    lbl.textAlignment = NSTextAlignmentCenter;
    lbl.textColor = TEXT_COLOR_999999;
	lbl.numberOfLines = 0;
	lbl.font = [UIFont systemFontOfSize:12];
    [self.view addSubview:lbl];
    [super initTableView];
    [baseTableview setBackgroundColor:[UIColor clearColor]];
    baseTableview.scrollEnabled = NO;
	baseTableview.frame = CGRectMake(HO_HORIZONAL_PADDING,
									 baseTableview.frame.origin.y,
									 self.view.frame.size.width - 2 * HO_HORIZONAL_PADDING,
									 baseTableview.frame.size.height);
//	baseTableview.layer.borderWidth = 2;
//	baseTableview.layer.borderColor = MAIN_COLOR_NORMAL.CGColor;
//	baseTableview.layer.cornerRadius = 5;
//	[baseTableview.layer setMasksToBounds:YES];
	baseTableview.separatorStyle = UITableViewCellSeparatorStyleNone;
//    baseTableview.layer.borderWidth = 1;
    // Do any additional setup after loading the view.
//    lbl.font = [UIFont systemFontOfSize:18];
	
	UIImageView *imgView = [[[UIImageView alloc]
							 initWithFrame:CGRectMake((self.view.frame.size.width - 180) / 2,
													  260,
													  180,
													  180)] autorelease] ;
	imgView.image = [UIImage imageNamed:@"qcode"];
	[self.view addSubview:imgView];
	
}
- (void)cellLongPress:(UIGestureRecognizer *)recognizer{
    if (recognizer.state == UIGestureRecognizerStateBegan) {
        HOBaseTableViewCell *cell = (HOBaseTableViewCell *)recognizer.view;
        [cell becomeFirstResponder];
        
        UIMenuItem *itCopy = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"拷贝", @"拷贝") action:@selector(copyCode:)];
        UIMenuController *menu = [UIMenuController sharedMenuController];
        [menu setMenuItems:[NSArray arrayWithObjects:itCopy,  nil]];
        
        UILabel *valueLbl = (UILabel *)[cell viewWithTag:22];
        [menu setTargetRect:valueLbl.frame inView:cell];
        [menu setMenuVisible:YES animated:YES];
        
        [itCopy release];
    }
}
- (void)cellLongPress1:(UIGestureRecognizer *)recognizer{
	if (recognizer.state == UIGestureRecognizerStateBegan) {
		HOBaseTableViewCell *cell = (HOBaseTableViewCell *)recognizer.view;
		[cell becomeFirstResponder];
		
		UIMenuItem *itCopy = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"拷贝", @"拷贝") action:@selector(copyCode1:)];
		UIMenuController *menu = [UIMenuController sharedMenuController];
		[menu setMenuItems:[NSArray arrayWithObjects:itCopy,  nil]];
		
		UILabel *valueLbl = (UILabel *)[cell viewWithTag:22];
		[menu setTargetRect:valueLbl.frame inView:cell];
		[menu setMenuVisible:YES animated:YES];
		
		[itCopy release];
	}
}
- (void)handleCopyCell:(id)sender{//复制cell
}

- (void)handleDeleteCell:(id)sender{//删除cell
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated
{
	self.tabBarController.tabBar.hidden = YES;
    [self setNavigationItemTitle:NSLocalizedString(@"关于邵医报修", @"关于邵医报修")];
    [super viewWillAppear:animated];
}
#pragma mark - -- UITableViewDelegate/UITableViewDataResource implement methods
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 0;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}


- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 240;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [[[UIView alloc]
                    initWithFrame:CGRectMake(0,
                                             0,
                                             tableView.frame.size.width,
											 240)] autorelease];
	UIImage *image = [UIImage imageNamed:@"app_icon"];
    UIImageView *imgView = [[[UIImageView alloc]
                            initWithFrame:CGRectMake((tableView.frame.size.width - image.size.width) / 2,
                                                     (200 - image.size.height) / 2,
                                                     image.size.width,
                                                     image.size.height)] autorelease];
    imgView.image = image;
    [view addSubview:imgView];
    
    UILabel *lbl = [[[UILabel alloc]
                     initWithFrame:CGRectMake(2 * HO_HORIZONAL_PADDING,
                                              imgView.frame.size.height + imgView.frame.origin.y,
                                              tableView.frame.size.width - 4 * HO_HORIZONAL_PADDING,
                                              120)] autorelease];
    lbl.textAlignment = NSTextAlignmentCenter;
    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];//正式版本号，类似2.0.8
    NSString *buildVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];//内部版本号  类似2017.02.16.01
	version = [NSString stringWithFormat:@"%@  (%@)", version, buildVersion];
    lbl.numberOfLines = 0;
	lbl.font = [UIFont systemFontOfSize:15];
	lbl.textColor = TEXT_COLOR_181818;
	if(isUnitfiedVersion)
	{
		lbl.text = [NSString stringWithFormat:@"%@ v%@\n\n%@",NSLocalizedString(@"邵医报修", @"邵医报修"), version, NSLocalizedString(@"高效后勤\n提升维修效率，质量，满意度\n\n APP下载二维码如下:", @"邵医报修，高效后勤。\n提升维修效率，质量，满意度\n\n APP下载二维码如下:")];
		[view addSubview:lbl];
	}
	else
	{
		lbl.text = [NSString stringWithFormat:@"%@ v%@\n\n%@",NSLocalizedString(@"邵医报修", @"邵医报修"), version, NSLocalizedString(@"邵医报修，高效后勤\n提升维修效率，质量，满意度\n\n APP下载二维码如下:", @"邵医报修，高效后勤\n提升维修效率，质量，满意度\n\n APP下载二维码如下:")];
		[view addSubview:lbl];
	}
    
    return view;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *AMBaseTableViewCellIdentifier = @"AMBaseTableViewCellIdentifier";
    HOBaseTableViewCell *cell = (HOBaseTableViewCell *)[tableView dequeueReusableCellWithIdentifier:AMBaseTableViewCellIdentifier];
    if(cell == nil)
    {
        cell = [[[HOBaseTableViewCell alloc]
                 initWithStyle:UITableViewCellStyleDefault
                 reuseIdentifier: AMBaseTableViewCellIdentifier] autorelease];
    }
    return cell;
}

- (void)callPhone:(id)sender
{
	[HOUtils callPhoneNumber:kHOServicePhoneNumber];
}
- (void)callPhone1:(id)sender
{
	[HOUtils callPhoneNumber:kHOServicePhoneNumber];

}
- (void)copyCode:(id)sender
{
    [UIPasteboard generalPasteboard].string = @"021-98989898";
}

- (void)copyCode1:(id)sender
{
	[UIPasteboard generalPasteboard].string = @"021-78787878";
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
	if(alertView.tag != 2340)
	{
		[super alertView:alertView clickedButtonAtIndex:buttonIndex];
	}
    if(buttonIndex == 1)
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://4006602522"]];
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
